package productmanagementclient.rmi;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.List;

import productmanagementclient.db.adapter.ProductAdapter;
import productmanagementclient.db.adapter.UserAdapter;
import productmanagementclient.publish.Product;
import productmanagementclient.publish.ProductRemote;
import productmanagementclient.publish.User;

public class ProductRemoteImpl extends UnicastRemoteObject implements
		ProductRemote {

	private static final long serialVersionUID = 1L;

	public ProductRemoteImpl() throws RemoteException {
		super();
	}

	public List<Product> getAllProduct() throws RemoteException {
		return ProductAdapter.getInstance().getAllProduct();
	}

	public Long saveProduct(Product product) throws RemoteException {
		return ProductAdapter.getInstance().saveProduct(product);
	}

	public void updateProduct(Product newProduct) throws RemoteException {
		ProductAdapter.getInstance().updateProduct(newProduct);
	}

	public void deleteProduct(Long productId) throws RemoteException {
		ProductAdapter.getInstance().deleteProduct(productId);
	}

	public Product getProductById(Integer productID) throws RemoteException {
		return ProductAdapter.getInstance().getProductById(productID);
	}

	public Product getProductByName(String productName) throws RemoteException {
		return ProductAdapter.getInstance().getProductByName(productName);
	}

	public List<User> getAllUser() throws RemoteException {
		return UserAdapter.getInstance().getAllUser();
	}

	public Long saveUser(User user) throws RemoteException {
		return UserAdapter.getInstance().saveUser(user);
	}

	public void updateUser(User newUser) throws RemoteException {
		UserAdapter.getInstance().updateUser(newUser);
	}

	public void deleteUser(Long userId) throws RemoteException {
		UserAdapter.getInstance().deleteUser(userId);
	}

	public User getUserById(Integer userID) throws RemoteException {
		return UserAdapter.getInstance().getUserById(userID);
	}

	public User getUserByName(String userName) throws RemoteException {
		return UserAdapter.getInstance().getUserByName(userName);
	}

}
